package cn.com.czpb.client.module.news.view;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;

import cn.com.czpb.client.R;
import cn.com.czpb.client.config.CODE;
import cn.com.czpb.client.utils.SPUtil;

/**
 * Created by 猪猪侠 on 2017/7/25.
 */

public class ZhengwuTopView implements View.OnClickListener {
    private View rootView;
    private Activity mActivity;
    protected SPUtil spu;//
    private RelativeLayout rl_id_2;
    private RelativeLayout rl_id_1;
    private RelativeLayout rl_id_3;
    RefreshListener listener;

    public static ZhengwuTopView instance(Activity activity){
        return new ZhengwuTopView(activity);
    }
    public ZhengwuTopView(Activity activity){
        //
        spu =SPUtil.getInstance();
        this.mActivity = activity;
        initView(activity);
    }
public void setRefreshListener(RefreshListener listener){
    this.listener = listener;
}
    public View getView(){
        return rootView;
    }
    /**
     * @param context
     */
    private void initView(Activity context) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        rootView = layoutInflater.inflate(R.layout.header_zhengwu,null);
        rl_id_1 = rootView.findViewById(R.id.rl_id_1);
        rl_id_2 = rootView.findViewById(R.id.rl_id_2);
        rl_id_3 = rootView.findViewById(R.id.rl_id_3);
        rl_id_1.setOnClickListener(this);
        rl_id_2.setOnClickListener(this);
        rl_id_3.setOnClickListener(this);
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.rl_id_1:
                listener.refreshData(CODE.CID_ZIZHIQU);
                break;
            case R.id.rl_id_2:
                listener.refreshData(CODE.CID_JUTING);
                break;
            case R.id.rl_id_3:
                listener.refreshData(CODE.CID_DIQU);
                break;
        }
    }
    public interface RefreshListener{
        void refreshData(String code);
    }
}
